<template>
  <div>
    <span>
      <!-- 图片 -->
      <img :src="img" width="100%" height="100%" />
      <!-- 标题 -->
      <div class="xh">{{ title }}</div>
      <!-- 价格 -->
      <div class="price">￥{{ price }}</div>
      <!-- 加入购物车 -->
      <div class="car" @click="s">加入购物车</div>
    </span>
  </div>
</template>

<script>
export default {
  props: {
    // 商品索引号
    sy: "",
    // 标题
    title: "",
    // 图片
    img: "",
    // 价格
    price: "",
  },
  methods: {
    s() {
      const In = this.sy;

      this.$emit("getIn", In);
    },
  },
};
</script>

<style lang="less" scoped>
div {
  // 取消文字选中
  user-select: none;
}
span {
  position: relative;
  display: inline-block;
  border: 2px solid #b71c1c;
  margin: 60px;
  width: 220px;
  height: 220px;
}
.xh {
  position: absolute;
  font-size: 12px;
  top: -40px;
  left: 0px;
  width: 220px;
  text-align: center;
  color: #b71c1c;
  font-weight: 600;
}
.car {
  cursor: pointer;
  position: absolute;
  top: 240px;
  left: 70px;
  width: 75px;
  text-align: center;
  line-height: 20px;
  font-size: 9px;
  height: 20px;
  color: #b71c1c;
  border: 2px solid #b71c1c;
  border-radius: 5px;
}
.car:hover {
  color: #fff;
  background-color: #b71c1c;
}
.price {
  position: absolute;
  color: #b71c1c;
  font-weight: 600;
  font-size: 12px;
  bottom: 10px;
  left: 10px;
}
.input {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
}
</style>